package com.gshrms.recruitment.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gshrms.common.annotation.DataSource;
import com.gshrms.common.core.domain.AjaxResult;
import com.gshrms.common.core.domain.entity.SysDictData;
import com.gshrms.common.enums.DataSourceType;
import com.gshrms.common.utils.DictUtils;
import com.gshrms.common.utils.StringUtils;
import com.gshrms.recruitment.entity.RecruitmentApplicants;
import com.gshrms.recruitment.entity.RecruitmentInfoPosition;
import com.gshrms.recruitment.entity.RecruitmentInterview;
import com.gshrms.recruitment.entity.RecruitmentStrict;
import com.gshrms.recruitment.entity.param.RecruitmentFeedbackParam;
import com.gshrms.recruitment.entity.param.RecruitmentReportParam;
import com.gshrms.recruitment.mapper.RecruitmentApplicantsMapper;
import com.gshrms.recruitment.service.IRecruitmentApplicantsService;
import com.gshrms.setting.domain.StaffInfoField;
import com.gshrms.setting.domain.StaffInfoTable;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 应聘者信息表 服务实现类
 * </p>
 *
 * @author xj
 * @since 2025-03-31
 */
@Service
public class RecruitmentApplicantsServiceImpl extends ServiceImpl<RecruitmentApplicantsMapper, RecruitmentApplicants> implements IRecruitmentApplicantsService {

    @Autowired
    RecruitmentApplicantsMapper recruitmentApplicantsMapper;

    @Override
    @DataSource(DataSourceType.SLAVE)
    public RecruitmentApplicants insert(RecruitmentApplicants recruitmentApplicants) {
        recruitmentApplicantsMapper.insert(recruitmentApplicants);
        return recruitmentApplicants;
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<RecruitmentInfoPosition> vacancy() {
        return recruitmentApplicantsMapper.vacancy();
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public Integer notReadNum(Long userId) {

        Integer notReadNum = recruitmentApplicantsMapper.notReadNum(userId);

        return notReadNum;
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<RecruitmentInterview> myApplication(Long userId) {
        return recruitmentApplicantsMapper.myApplication(userId);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<RecruitmentStrict> strictRequirement(String positionId) {
        return recruitmentApplicantsMapper.strictRequirement(positionId);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<SysDictData> selectDictDataByType() {
        List<SysDictData> dictDatas = recruitmentApplicantsMapper.selectDictDataByType();
        return dictDatas;
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<StaffInfoTable> selectTable() {
        List<StaffInfoTable> staffInfoTableList = recruitmentApplicantsMapper.selectTable();
        for (StaffInfoTable staffInfoTable : staffInfoTableList) {
            List<StaffInfoField> list = recruitmentApplicantsMapper.selectField(staffInfoTable.getTableId());
            staffInfoTable.setStaffInfoFieldList(list);
        }
        return staffInfoTableList;
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public Integer feedback(RecruitmentFeedbackParam param) {
        return recruitmentApplicantsMapper.feedback(param);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public void uploadReport(RecruitmentReportParam param) {
        recruitmentApplicantsMapper.uploadReport(param);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public RecruitmentInfoPosition selectById(String positionId) {
        return recruitmentApplicantsMapper.selectRecruitmentInfoPositionById(positionId);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<String> myVacancy(Long userId) {
        return recruitmentApplicantsMapper.myVacancy(userId);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public void updateReadState(Long userId) {
        recruitmentApplicantsMapper.updateReadState(userId);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public Integer isRepeat(Long userId) {
        return recruitmentApplicantsMapper.isRepeat(userId);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public Integer delReport(RecruitmentReportParam param) {
        return recruitmentApplicantsMapper.delReport(param.getApplicantId());
    }

}
